﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using Common;

namespace CNCSoft.ErpApps.TMS.longGiaoVu
{
    public partial class frmAnnualReport : Form
    {
        public frmAnnualReport()
        {
            InitializeComponent();
        }

        private void frmAnnualReport_Load(object sender, EventArgs e)
        {

        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            string namereport = "myrpt_AnnualReport";
            PrintData(namereport);
        }

        #region "Coding"
        private void PrintData(string namereport)
        {
            try
            {
                btnXem.Enabled = false;
                //Load Report
                ReportDocument rpt = new ReportDocument();
                if(GlobalVariable.WSInfo.CompanyID.ToLower() == "english")
                    rpt.Load(Application.StartupPath + "\\Report\\" + namereport + ".rpt");
                //Set Connection
                PublicFunction.SetDBLogonForReport(rpt);

                frmPrintPreview view = new frmPrintPreview(rpt);
                view.ShowDialog();
                view.Dispose();
                rpt.Dispose();
                btnXem.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #endregion
    }
}
